package com.bing.bingPro.controller.fiveOrder;

import com.bing.bingPro.ExcelUtil;
import com.bing.bingPro.common.BaseResult;
import com.bing.bingPro.controller.dto.TFiveOrderTypeDto;
import com.bing.bingPro.controller.vo.TInstallOrderVo;
import com.bing.bingPro.service.TInstallOrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 工单详表-装机工单详表(t_install_order)
 */
@RestController
public class TInstallOrderController {

    @Resource
    private TInstallOrderService tInstallOrderService;

    /**
     * 装机工单详表-列表
     *
     * @param tOrderYearDto
     * @return
     */
    @PostMapping("/installList")
    public BaseResult<List<TInstallOrderVo>> installList(@RequestBody TFiveOrderTypeDto tOrderYearDto) {
        return new BaseResult<>(this.tInstallOrderService.installList(tOrderYearDto));
    }


    /**
     * 装机工单详表-导出
     *
     * @param response
     * @param tOrderYearDto
     * @throws Exception
     */
    @PostMapping("/export")
    public void exportInstall(HttpServletResponse response, @RequestBody TFiveOrderTypeDto tOrderYearDto) throws Exception {
        List<TInstallOrderVo> tInstallOrderVos = tInstallOrderService.exportInstall(tOrderYearDto);
        String monthOrDayTime = "装机工单详表" + tOrderYearDto.getTime();
        ExcelUtil.writeExcel(response, tInstallOrderVos, monthOrDayTime, "装机工单详表" + tOrderYearDto.getTime(), TInstallOrderVo.class);

    }
}
